<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../adspace/left.html">
            <!-- sidebar end -->
            <!-- content start-->
            <div class="admin-content">
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><@s.m "global.position"/>:规格管理  - <@s.m "global.add"/></div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <form class="ropt">
                            <input type="submit" value="<@s.m "global.backToList"/>" onclick="this.form.action='list.do';"/>
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <#assign fieldExist><@s.m "error.fieldExist"/></#assign>
                        <@p.form id="baseForm" action="o_save.do">
                        <@p.text label="规格名称" colspan="2" width="100" name="name" required="true" class="required" maxlength="100"/><@p.tr/>
                        <@p.text label="字段名称" colspan="2" width="100" name="field" required="true" vld="{required:true,rangelength:[3,100],remote:'check_field.do',messages:{remote:'${fieldExist}'}}" maxlength="100"/><@p.tr/>
                        <@p.text label="备注" colspan="2" width="100" name="remark" required="true" class="required" maxlength="100"/><@p.tr/>
                        <@p.radio label="类型" colspan="2" width="100" name="dataType" list={"true":"图片","false":"文字"} value="false" helpPosition="2"  required="true" class="required"/><@p.tr/>
                        <@p.text label="排序"  colspan="2" width="100" name="priority" value="10" required="true" class="required digits" maxlength="10"/><@p.tr/>
                        <@p.td colspan="2">
                        <div class="items">
                            &nbsp; <input type="button" value="增加规格值" onclick="addLines();"/>
                        </div>
                        <div id="itemsContainer">
                        </div>
                    </@p.td><@p.tr/>
                    <@p.td colspan="2" width="100"><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
            </@p.form>
    </div>
    <textarea id="itemTpl" style="display:none;">
        <div class="items">
            规格值名称 : <input type="text" name="itemName" style="width:200px"/>
            &nbsp; 颜色:<input type="text" id="itemColor{0}" name="itemColor" value="" style="width:70px"/>(规格为颜色时使用)
            &nbsp; 排序: <input type="text" name="itemPriority" value="{0}" style="width:30px"/>
            &nbsp; <input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="$(this).parent().remove();"/>
        </div>
    </textarea>
            </div>
    </div>



    </div>

    </div>


<script type="text/javascript">
var tpl = $.format($("#itemTpl").val());
var index = 1;
function addLines() {
	$("#itemsContainer").append(tpl(index++));
	$("#itemColor"+(index-1)).colorPicker();
}
</script>
</body>
</html>